/**
 * @file     hammingWeight.js
 * @brief    [191. 位1的个数](https://leetcode.cn/problems/number-of-1-bits/)
 * @author   Zhu
 * @date     2022-10-23 00:25
 */

/**
 * @param {number} n - a positive integer
 * @return {number}
 */
var hammingWeight = function (n) {
    let count = 0;
    do {
        count += n & 1;
    } while ((n = n >>> 1));

    return count;
};
